package 
{


import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.Sprite;
import flash.errors.IllegalOperationError;

import framework.core.ComponentBuilder;



/**
 * GameUI
 * @author jliang
 * 
 */
public class Game extends Sprite implements IGameFacade
{
	//==========================================================================
	//  Constructor
	//==========================================================================
	public function Game(enforce:SingletonEnforce)
	{
		super();
		if (!enforce)
		{
			throw new IllegalOperationError("Game is a singleton class.");
		}
	}
    //==========================================================================
    //  Class constants
    //==========================================================================
	private static var _instance:IGameFacade;

	public static function get instance():IGameFacade
	{
		if (!_instance) _instance = new Game(new SingletonEnforce());
		return _instance;
	}
    //==========================================================================
    //  Properties
    //==========================================================================
    public function get container():DisplayObjectContainer
    {
        return parent;
    }
    
    private var _sectionLayer:DisplayObjectContainer;
    
    public function get sectionLayer():DisplayObjectContainer
    {
        return _sectionLayer;
    }
	
	private var _mapLayer:DisplayObjectContainer;
	
	public function get mapLayer():DisplayObjectContainer
	{
		return _mapLayer;
	}
    
    private var _popUpLayer:DisplayObjectContainer;
    
    public function get popUpLayer():DisplayObjectContainer
    {
        return _popUpLayer;
    }
    
  
    //==========================================================================
    //  Public methods
    //==========================================================================	
	public function initialize(con:DisplayObjectContainer, params:Object):void
	{                
        con.addChild(this);
        
        //init layers
        _sectionLayer = new Sprite();
        sectionLayer.name = "sectionLayer";
        this.addChild(sectionLayer);
		
		_mapLayer = new Sprite();
		mapLayer.name = "mapLayer";
		this.addChild(mapLayer);
        
        _popUpLayer = new Sprite();
        popUpLayer.name = "popUpLayer";
        this.addChild(popUpLayer);
        
        //start();
        
        //check new player
        if (params.isNewPlayer == true)
        {
          
        }
        else
        {
            start();
        }
	}
    
    public function start():void
    {
      
		changeSection("city_section");
    }
	
	
  
}
}

class SingletonEnforce
{
	
}


